<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<%@include file="../base/frameBase.jsp" %>
<body>

<!-- 内容主体区域 -->
<div style="padding: 15px;width: 80%">
    <p id="title" style="font-size:22px"></p>
    <p id="author" style="font-size:16px"></p>
    <hr>
    <div id="context">

    </div>
</div>


<script>
    layui.use(['layer', 'element', 'table'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;

        var theRequest = new Object();
        // 加载url参数
        var url = location.search; //获取url中"?"符后的字串
        url = decodeURI(url);
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }
        console.log(theRequest);
        var id = theRequest.pageId;
        var param = {};
        param.id = id;
        $.ajax({
            url: '${ctx}/pageData/getPageById',
            method: 'GET',
            contentType: 'application/json',
            data: param,
            success: function (res) {
                console.log(res);
                if (res.code == "00000") {
                    $('#context').html(res.data.page_context);
                    $('#title').html(res.data.page_title);
                    $('#author').html('<span>'+res.data.createTime+
                        '</span>&nbsp;阅读数：<span>'+res.data.page_click+'</span>'
                        // + '</span>&nbsp;点赞数：<span>'+res.data.page_like+'</span>')
                    )
                } else {
                    layer.msg(res.msg)
                }
            },
            error: function (res) {
                alert(res.data);
            }
        })
        return false;
    })
</script>
<%@include file="../base/frameFoot.jsp" %>